package com.cxl.autocode.create;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletContext;

import com.cxl.autocode.data.SmrFrame;
import com.summer.core.entity.STable;
/**
 * 生成.java实现代码
 * @author Administrator
 *
 */
public class JavaGeneratorImpl extends AbstractGenerator implements JavaGenerator{

	public void genDaoInterface(SmrFrame path,STable bean){
		 Map<String, Object> data = new HashMap<String, Object>();
	     data.put("model", path);
	     data.put("table", bean);
	     String filePath=new String("src/"+package2path(path.getDaoPackage()+"/"+path.getDaoName()));
	     super.generate(path.dao, data, filePath+".java");
		
	}
	public void genDaoImpl(SmrFrame path,STable bean){
		 Map<String, Object> data = new HashMap<String, Object>();
	     data.put("model", path);
	     data.put("table", bean);
	     String filePath=new String("src/"+package2path(path.getDaoImplPackage()+"/"+path.getDaoImplName()));
	     super.generate(path.daoImpl, data, filePath+".java");
	}
	

	public void genAction(SmrFrame path,STable bean) {
		 Map<String, Object> data = new HashMap<String, Object>();
	     data.put("model", path);
	     data.put("table", bean);
	     String filePath=new String("src/"+package2path(path.getActionPackage()+"/"+path.getActionName()));
	     super.generate(path.action, data, filePath+".java");
		
	}

	public void genServiceImpl(SmrFrame path,STable bean) {
		 Map<String, Object> data = new HashMap<String, Object>();
	     data.put("model", path);
	     data.put("table", bean);
	     String filePath=new String("src/"+package2path(path.getServiceImplPackage()+"/"+path.getServiceImplName()));
	     super.generate(path.serviceImpl, data, filePath+".java");
		
	}
	
	public void genServiceInterface(SmrFrame path,STable bean) {
		 Map<String, Object> data = new HashMap<String, Object>();
	     data.put("model", path);
	     data.put("table", bean);
	     String filePath=new String("src/"+package2path(path.getServicePackage()+"/"+path.getServiceName()));
	     super.generate(path.service, data, filePath+".java");
		
	}
	
	
	public void genDaoInterface(ServletContext context,SmrFrame path,STable bean){
		 Map<String, Object> data = new HashMap<String, Object>();
	     data.put("model", path);
	     data.put("table", bean);
	     String filePath=new String("src/"+package2path(path.getDaoPackage()+"/"+path.getDaoName()));
	     super.generate(context,path.dao, data, filePath+".java");
		
	}
	public void genDaoImpl(ServletContext context,SmrFrame path,STable bean){
		 Map<String, Object> data = new HashMap<String, Object>();
	     data.put("model", path);
	     data.put("table", bean);
	     String filePath=new String("src/"+package2path(path.getDaoImplPackage()+"/"+path.getDaoImplName()));
	     super.generate(context,path.daoImpl, data, filePath+".java");
	}
	

	public void genAction(ServletContext context,SmrFrame path,STable bean) {
		 Map<String, Object> data = new HashMap<String, Object>();
	     data.put("model", path);
	     data.put("table", bean);
	     String filePath=new String("src/"+package2path(path.getActionPackage()+"/"+path.getActionName()));
	     super.generate(context,path.action, data, filePath+".java");
		
	}

	public void genServiceImpl(ServletContext context,SmrFrame path,STable bean) {
		 Map<String, Object> data = new HashMap<String, Object>();
	     data.put("model", path);
	     data.put("table", bean);
	     String filePath=new String("src/"+package2path(path.getServiceImplPackage()+"/"+path.getServiceImplName()));
	     super.generate(context,path.serviceImpl, data, filePath+".java");
		
	}
	
	public void genServiceInterface(ServletContext context,SmrFrame path,STable bean) {
		 Map<String, Object> data = new HashMap<String, Object>();
	     data.put("model", path);
	     data.put("table", bean);
	     String filePath=new String("src/"+package2path(path.getServicePackage()+"/"+path.getServiceName()));
	     super.generate(context,path.service, data, filePath+".java");
		
	}
	
	
}
